<?php
/**
 * Created by PhpStorm.
 * User: zhj
 * Date: 2019/1/16
 * Time: 14:42
 */
namespace app\common\validate;
class User extends ValidateBase
{

    // 验证规则
    public $rule = [
        'nickname'  => 'require|length:6,30',
        'password'  => 'require|length:6,30',
        'phone'    => 'require|length:11|unique:user',
    ];

    // 验证提示
    protected $message = [
        'nickname.require'    => '用户名不能为空',
        'nickname.length'     => '用户名长度为6-30个字符之间',
        'password.require'    => '密码不能为空',
        'password.length'     => '密码长度为6-30个字符之间',
        'password.confirm'     => '密码输入不一致',
        'phone.require'      => '手机号码不能为空',
        'phone.unique'      => '手机号码已存在',
        'phone.length'      => '手机号码不正确',
    ];

    // 应用场景
    protected $scene = [
        'add'  =>  ['nickname','password','phone'],
        'login'=>  ['nickname','password']
    ];
}
